package com.base.helper;

import com.base.comm.CommUrls;
import com.base.utils.Md5Encrypt;

import javax.servlet.http.HttpServletRequest;

public class EIGHTFHelper {
        private static String appid="21519";
        private static String appkey="21519876";

        private static String URL_CALL="http://ybd.yaloe.com/webapi.php?act=call";
    /**
     * Call
     * @param mynumber  主叫
     * @param callnumber 被叫
     * @return
     */
    public static String getCall(HttpServletRequest request, String mynumber, String callnumber,String params,int max) {
        // 获取域名
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
        // 回调地址
        String return_url = CommUrls.THISSERVER + "call/Eight8Notify";
        String sign = null; // MD5加密
        try {
            /**
             *  @Date: 2019/9/27 14:57
             *  @Description:
             *  对参数不限制MAX通话时间，Param表示自定义参数,回调的时候,会返回
             *     String str="&appid=21519&callnumber=18055603791&feetype=1&mynumber=18368001096&return_url=http://www.callback.com21519876";
             */
            String str="&appid=" + appid + "&callnumber=" + callnumber + "&feetype=1"
                    + "&mynumber="+mynumber+"&return_url="+return_url+appkey;
            sign = Md5Encrypt.encrypt32(str);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String url = URL_CALL+"&appid="+appid+ "&mynumber=" + mynumber + "&callnumber="
                + callnumber +"&feetype=1"+ "&return_url="+return_url+"&sign=" + sign;
        String json = null;
        try {
            json = WebHelper.GetData(url, null);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }

}
